﻿/* Global Variables */
var _gaq = _gaq || [];
var environment = environment || '';

/* Page Load */
$(function () {
    SetupGoogleAnalytics();
});

/* Setup Methods */
function SetupGoogleAnalytics() {
    environment = $('#hdnfld_Environment').val();
    if (environment == "Development") {
        _gaq.push(['_setAccount', 'UA-40840067-1']);
    }
    else if (environment == "Production") {
        _gaq.push(['_setAccount', 'UA-40840067-2']);
    }

    _gaq.push(['_setDomainName', 'none']);
    _gaq.push(['_setAllowLinker', true]);
    _gaq.push(['_setSiteSpeedSampleRate', 100]);
    _gaq.push(['_trackPageview']);

    var ga = document.createElement('script');
    ga.type = 'text/javascript';
    ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';

    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(ga, s);
}

/* Helper Methods */
function AJAXWrapper(method, data, onSuccess, onError) {
    $.ajax({
        type : "POST",
        url : method,
        data : data,
        contentType : "application/json; charset=utf-8",
        dataType : "json",
        success : onSuccess,
        error : onError

    });
}